//
// Date Select
// ==============================

// Inspired by https://github.com/twbs/bootstrap




// Normalize
// ------------------------------

.DateSelect {
	font-size: @DateSelect-font-size;
	font-family: @DateSelect-font-family;
	-webkit-font-smoothing: antialiased;

	* {
		#DateSelect .box-sizing(border-box);
	}
	button,
	input,
	select {
		font-size: inherit;
		font-family: inherit;
		margin: 0;
		-webkit-appearance: none;
		   -moz-appearance: none;
	}
}




// Dialog
// ------------------------------



// shell div to position the date picker
.DateSelect-dialog {
	left: 0;
	margin-left: auto;
	margin-right: auto;
	position: absolute;
	right: 0;
	top: 0;
	width: 100%;
	z-index: @DateSelect-dialog-zindex;
}
.modal-dialog-enter {
	#DateSelect .animation-name( modalDialogEnter );
	#DateSelect .animation-duration( 280ms );
	#DateSelect .animation-timing-function( cubic-bezier(0.680, -0.550, 0.265, 1.550) );
}
.modal-dialog-leave {
	#DateSelect .animation-duration( 140ms );
	#DateSelect .animation-name( modalDialogLeave );
}


// actual date picker

.DateSelect-content {
	background-color: @DateSelect-bg;
	outline: none; // remove focus outline from opened date picker
	position: relative;
}




// Days - Common
// ------------------------------

.DateSelectCalendar__legend,
.DateSelectCalendar__month {
	#DateSelect .clearfix();
}
.DateSelectCalendar__legend {
	padding: @DateSelect-padding @DateSelect-padding 0;
}
.DateSelectCalendar__month {
	padding: 0 @DateSelect-padding @DateSelect-padding;
}
.DateSelectCalendar__legend__day,
.DateSelectCalendar__month__day {
	float: left;
	font-size: inherit;
	line-height: 1;
	padding: 10px 2px;
	position: relative;
	text-align: center;
	width: 14.286%;
}




// Title
// ------------------------------


// base

.DateSelectCalendar__toolbar {
	border-bottom: 1px solid @DateSelect-footer-border;
	position: relative;
	text-align: center;
}


// selects

.DateSelectCalendar__toolbar__select {
	background: none;
	border: none;
	display: inline-block;
	font-size: inherit;
	font-weight: 500;
	line-height: @DateSelect-title-button-height;
	padding-left: .5em;
	padding-right: .5em;

	&:focus {
		color: @DateSelect-primary;
		outline: none;
	}
}


// buttons

.DateSelectCalendar__toolbar__button {
	background-color: transparent;
	background-image: none;
	background-position: center center;
	background-repeat: no-repeat;
	background-size: @DateSelect-title-button-width @DateSelect-title-button-height;
	border: none;
	display: inline-block;
	height: @DateSelect-title-button-height;
	opacity: .6;
	overflow: hidden;
	position: absolute;
	text-indent: -9999px;
	top: 0;
	white-space: nowrap;
	width: @DateSelect-title-button-width + (@DateSelect-padding * 2);

	&:hover {
		opacity: 1;
	}
}

.DateSelectCalendar__toolbar__button--prev {
	background-image: url("");
	left: 0;
}
.DateSelectCalendar__toolbar__button--next {
	background-image: url("");
	right: 0;
}




// Legend
// ------------------------------

.DateSelectCalendar__legend {
	color: @DateSelect-legend-color;
	font-weight: 500;
}
.DateSelectCalendar__legend__day {
	border-bottom: none;
	cursor: default;
}




// Calendar
// ------------------------------

.DateSelectCalendar__month__day {
	background: none;
	border: none;
	border-radius: @DateSelect-border-radius-inner;
	outline: none;

	&:hover {
		background-color: mix(@DateSelect-primary, @DateSelect-bg, 10%);
	}
	&:focus {
		box-shadow: 0 0 0 1px @DateSelect-bg, 0 0 0 3px fade(@DateSelect-primary, 15%);
		color: @DateSelect-primary;
		outline: 0;
	}
	&:active {
		background-color: darken(@DateSelect-selected-day-bg, 5%);
		box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
		color: @DateSelect-selected-day-color;
	}

	// current day
	&.is-current-day {
		background-color: @DateSelect-current-day-bg;
		box-shadow: inset 0 0 0 1px @DateSelect-current-day-border;

		&.is-selected {
			box-shadow: none;

			&:focus {
				box-shadow: 0 0 0 1px @DateSelect-bg, 0 0 0 3px fade(@DateSelect-primary, 15%);
				outline: 0;
			}
		}
	}

	// selected day
	&.is-selected {
		background-color: @DateSelect-selected-day-bg;
		color: @DateSelect-selected-day-color;
	}
}

// add an arrow on multi pickers

.multi-picker .DateSelectCalendar:first-child .DateSelectCalendar__month__day.is-selected,
.multi-picker .DateSelectCalendar:last-child .DateSelectCalendar__month__day.is-selected {

	&::after {
		border-bottom:  5px solid transparent;
		border-top: 5px solid transparent;
		content: "";
		height: 0;
		margin-top: -5px;
		position: absolute;
		top: 50%;
		width: 0;
		z-index: 1;
	}
}
.multi-picker .DateSelectCalendar:first-child .DateSelectCalendar__month__day.is-selected::after {
	border-left: 5px solid @DateSelect-primary;
	right: -5px;
}
.multi-picker .DateSelectCalendar:last-child .DateSelectCalendar__month__day.is-selected::after {
	border-right: 5px solid @DateSelect-primary;
	left: -5px;
}
.multi-picker .DateSelectCalendar:first-child .is-after-selected-day {
	border-radius: 0;
	background-color: mix(@DateSelect-primary, @DateSelect-bg, 5%);
	color: mix(@DateSelect-primary, @DateSelect-text-color, 50%);
}
.multi-picker .DateSelectCalendar:last-child .is-before-selected-day {
	border-radius: 0;
	background-color: mix(@DateSelect-primary, @DateSelect-bg, 5%);
	color: mix(@DateSelect-primary, @DateSelect-text-color, 50%);
}




// Body
// ------------------------------

.DateSelect-body {
}




// Header
// ------------------------------


// base

.DateSelectHeader {
	#DateSelect .gradient-vertical(lighten(@DateSelect-header-bg, 4%), darken(@DateSelect-header-bg, 4%));
	background-color: @DateSelect-header-bg;
	box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.1), 0 1px 0 white;
	color: @DateSelect-header-color;
	display: block;
	text-align: center;
}


// expanded

.DateSelectHeader--expanded {
	line-height: 1;

	> .DateSelectHeader {
		display: block;
		font-weight: 300;
	}
	> .DateSelectHeader__dow {
		background-color: rgba(0, 0, 0, 0.1);
		border-top-right-radius: @DateSelect-border-radius-outer;
		border-top-left-radius: @DateSelect-border-radius-outer;
		display: block;
		font-size: .85em;
		padding: 5px;
	}
	> .DateSelectHeader__month {
		display: block;
		padding-top: 10px;
		text-transform: uppercase;
	}
	> .DateSelectHeader__day {
		display: block;
		font-size: 4em;
		margin-bottom: 5px;
		margin-top: 5px;
	}
	> .DateSelectHeader__year {
		color: rgba(255, 255, 255, 0.75);
		display: block;
		padding-bottom: 10px;
	}
}


// condensed

.DateSelectHeader--condensed {
	font-weight: bold;
	letter-spacing: 0.0125em;
	padding: @DateSelect-padding;

	> .DateSelectHeader,
	> .DateSelectHeader__dow,
	> .DateSelectHeader__month,
	> .DateSelectHeader__day,
	> .DateSelectHeader__year {
		display: inline-block;
		margin-left: .15em;
		margin-right: .15em;
	}

	> .DateSelectHeader__dow {
		opacity: .75;
		display: block;
		font-size: .75em;
		font-weight: 500;
		margin: 0;
		text-transform: uppercase;
		-webkit-font-smoothing: antialiased;
	}
}




// Ranges
// ------------------------------


// base

.DateSelect__range {
	border-top: 1px solid @DateSelect-footer-border;
	display: table;
	font-size: .85em;
	position: relative;
	text-align: center;
	width: 100%;

	// dim on hover
	&:hover {
		color: lighten(@DateSelect-text-color, 20%);
	}
}


// items

.DateSelect__range__item {
	#DateSelect .transition( color 200ms );
	background-color: transparent;
	background-image: none;
	border: none;
	color: inherit;
	cursor: pointer;
	display: inline-block;
	outline: none;
	padding: @DateSelect-padding;
	position: relative;
	text-align: center;

	&:hover {
		color: darken(@DateSelect-text-color, 20%);
	}
	&.active,
	&:focus {
		box-shadow: 0 1px 0 @DateSelect-range-color;
		color: darken(@DateSelect-text-color, 20%);

		&:after {
			border-bottom: 4px solid @DateSelect-range-color;
			border-left:   4px solid transparent;
			border-right:  4px solid transparent;
			bottom: 0;
			content: "";
			display: inline-block;
			height: 0;
			left: 50%;
			margin-left: -4px;
			position: absolute;
			width: 0;
		}
	}
}




// Footer
// ------------------------------

.DateSelectFooter {
	#DateSelect .clearfix();
	background-color: @DateSelect-footer-bg;
	border-top: 1px solid @DateSelect-footer-border;
	border-bottom-right-radius: @DateSelect-border-radius-outer;
	border-bottom-left-radius: @DateSelect-border-radius-outer;
}
.DateSelectFooter__button {
	background-color: transparent;
	background-image: none;
	border: none;
	border-radius: 0;
	color: @DateSelect-footer-color;
	float: left;
	font-size: inherit;
	outline: none;
	padding: @DateSelect-padding;
	text-align: center;
	width: 50%;

	&:last-child {
		border-left: 1px solid @DateSelect-footer-border;
	}
}
.DateSelectFooter__button--primary {
	color: @DateSelect-footer-single-button-primary-color;
	font-weight: @DateSelect-footer-button-font-weight-primary;
}




// Single Day Picker
// ------------------------------

.single-picker {
	.DateSelectFooter__button {
		&:hover,
		&:focus {
			background-color: @DateSelect-footer-single-button-hover-bg;
		}
		&:active {
			background-color: @DateSelect-footer-single-button-active-bg;
		}

		&:first-child {
			border-bottom-left-radius: @DateSelect-border-radius-outer;
		}
		&:last-child {
			border-bottom-right-radius: @DateSelect-border-radius-outer;
		}
	}
}




// Multi Picker
// ------------------------------

.multi-picker {
	// footer
	.DateSelectFooter {
		padding: (@DateSelect-padding * 1.5) (@DateSelect-padding * 2);
	}
	.DateSelectFooter__button {
		background: none;
		border-radius: .25em;
		border: none;
		cursor: pointer;
		display: inline-block;
		float: none;
		font-size: inherit;
		height: 2.4em;
		line-height: 2.3em;
		margin-bottom: 0;
		overflow: hidden; // contain gradient on IE9
		padding: 0 1em;
		text-align: center;
		touch-action: manipulation;
		vertical-align: middle;
		white-space: nowrap;
		width: 80px;

		&:hover,
		&:focus,
		&.focus {
			color: @DateSelect-footer-multi-button-hover-color;
			text-decoration: none;
		}

		&:active,
		&.active {
			background-image: none;
			outline: 0;
		}

		&.disabled,
		&[disabled] {
			opacity: .4;
			pointer-events: none;
		}
	}
	.DateSelectFooter__button--primary {
		#DateSelect .gradient-vertical(lighten(@DateSelect-footer-multi-button-primary-bg, 4%), darken(@DateSelect-footer-multi-button-primary-bg, 4%));
		background-color: @DateSelect-footer-multi-button-primary-bg;
		color: @DateSelect-footer-multi-button-primary-color;

		&:hover,
		&:focus,
		&.focus {
			#DateSelect .gradient-vertical(lighten(@DateSelect-footer-multi-button-primary-bg, 8%), @DateSelect-footer-multi-button-primary-bg);
			color: @DateSelect-footer-multi-button-primary-color;
			outline: none;
		}
		&:focus,
		&.focus {
			box-shadow: 0 0 0 3px fade(@DateSelect-footer-multi-button-primary-bg, 25%);
		}
		&:active,
		&.active {
			background-color: darken(@DateSelect-footer-multi-button-primary-bg, 5%);
			background-image: none;
			box-shadow: none;
		}
	}
}




// InlineCalendar
// ------------------------------

.DateSelect-inline-container {
	border-radius: @DateSelect-border-radius-outer;
	box-shadow: 0 0 0 1px rgba(0,0,0,.175);
	width: @DateSelect-dialog-width;
}


// Sizes
// ------------------------------

@media (min-width: @DateSelect-screen-sm-min) {
	.DateSelect-dialog {
		margin-bottom: 100px;
		margin-top: 100px;
		width: @DateSelect-dialog-width;
	}
	.DateSelect-content {
		border-radius: @DateSelect-border-radius-outer;
		box-shadow: 0 0 0 1px rgba(0,0,0,.175), 0 3px 8px rgba(0,0,0,.175);
	}
	.DateSelectHeader {
		border-top-right-radius: @DateSelect-border-radius-outer;
		border-top-left-radius: @DateSelect-border-radius-outer;
	}
	.multi-picker {
		.DateSelect-body {
			#DateSelect .clearfix();
		}
		.DateSelect-dialog {
			width: (@DateSelect-dialog-width * 2);
		}
		.DateSelectHeader {
			border-radius: 0;
			box-shadow: -1px 0 0 darken(@DateSelect-header-bg, 10%);
		}
		.DateSelectCalendar {
			border-left: 1px solid @DateSelect-footer-border;
			float: left;
			width: 50%;

			&:first-child {
				border-left: none;
				.DateSelectHeader {
					border-top-left-radius: @DateSelect-border-radius-outer;
					box-shadow: none;
				}
			}
			&:last-child .DateSelectHeader {
				border-top-right-radius: @DateSelect-border-radius-outer;
			}
		}
	}
}




// Background
// ------------------------------

.DateSelect-backdrop {
	#DateSelect .animation-duration( 140ms );
	background-color: @DateSelect-backdrop-bg;
	height: 100%;
	left: 0;
	position: fixed;
	top: 0;
	width: 100%;
	z-index: @DateSelect-backdrop-zindex;
}
.modal-backdrop-enter {
	#DateSelect .animation-name( modalBackdropEnter );
}
.modal-backdrop-leave {
	#DateSelect .animation-delay( 240ms );
	#DateSelect .animation-name( modalBackdropLeave );
}




// Animation
// --------------------


// modal dialog

@-webkit-keyframes modalDialogEnter {
	from { opacity: 0; -webkit-transform: scale( .8 ); }
	to { opacity: 1; -webkit-transform: scale( 1 ); }
}
@keyframes modalDialogEnter {
	from { opacity: 0; transform: scale( .8 ); }
	to { opacity: 1; transform: scale( 1 ); }
}

@-webkit-keyframes modalDialogLeave {
	from { opacity: 1; -webkit-transform: scale( 1 ); }
	to { opacity: 0; -webkit-transform: scale( .8 ); }
}
@keyframes modalDialogLeave {
	from { opacity: 1; transform: scale( 1 ); }
	to { opacity: 0; transform: scale( .8 ); }
}


// modal backdrop

@-webkit-keyframes modalBackdropEnter {
	from { opacity: 0; }
	to { opacity: 1; }
}
@keyframes modalBackdropEnter {
	from { opacity: 0; }
	to { opacity: 1; }
}

@-webkit-keyframes modalBackdropLeave {
	from { opacity: 1; }
	to { opacity: 0; }
}
@keyframes modalBackdropLeave {
	from { opacity: 1; }
	to { opacity: 0; }
}
